﻿using ProjectManageSystemApi.DbEntity;
using ProjectManageSystemApi.Models.UserCheckDetailModel;
using System;
using System.Collections.Generic;

namespace ProjectManageSystemApi.Models
{
	public class UserCheckInfoDto 
	{
		public long UserId { get; set; }
		public string UserName { get; set; }
		public string Roles { get; set; }
		public int TotalCount { get; set; }
		public int CheckCount { get; set; }
		public decimal TotalPrice 
		{ 
			get 
			{
				decimal totalPrice = 0;
				foreach (var d in UserCheckData) 
				{
					totalPrice += d.TotalPrice;
				}
				return Math.Round(totalPrice, 2);
			} 
		}
		public IEnumerable<UserCheckDto> UserCheckData { get; set; } = new List<UserCheckDto>();
	}
	public class UserCheckDto
	{
		public uint Id { get; set; }

		/// <summary>
		/// 考勤日期
		/// </summary>
		public DateTime BelongsDate { get; set; }

		/// <summary>
		/// 上班时间
		/// </summary>
		public DateTime? ClockInDate { get; set; }

		/// <summary>
		/// 上班打卡图片
		/// </summary>
		public string ClockInPicUrl { get; set; }

		/// <summary>
		/// 下班时间
		/// </summary>
		public DateTime? ClockOutDate { get; set; }

		/// <summary>
		/// 下班打卡图片
		/// </summary>
		public string ClockOutPicUrl { get; set; }

		public decimal TotalPrice 
		{ 
			get 
			{
				decimal totalPrice = 0m;
				foreach (var d in Detail) 
				{
					totalPrice += d.Price * d.NumberOfPeople;
				}
				return Math.Round(totalPrice, 2);
			}
		}

		/// <summary>
		/// 用户id
		/// </summary>
		public long? UserId { get; set; }

		public string UserName { get; set; }
		public string Roles { get; set; }
		
		public List<UserCheckDetailDto> Detail { get; set; } = new List<UserCheckDetailDto>();
	}

	public class UserCheckSqlDto 
	{
		public UserCheckInfo UserCheckInfo { get; set; }
        public string UserName { get; set; }
		public string Roles { get; set; }
		public List<UserCheckDetail> Details { get; set; } = new List<UserCheckDetail>();
	}
}
